1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module sourceview.Language; 26 27 private import glib.Str; 28 private import glib.c.functions; 29 private import gobject.ObjectG; 30 private import sourceview.c.functions; 31 public import sourceview.c.types; 32 33 34 /** 35 * Represents a syntax highlighted language. 36 * 37 * A `GtkSourceLanguage` represents a programming or markup language, affecting 38 * syntax highlighting and [context classes](./class.Buffer.html#context-classes). 39 * 40 * Use [class@LanguageManager] to obtain a `GtkSourceLanguage` instance, and 41 * [method@Buffer.set_language] to apply it to a [class@Buffer]. 42 */ 43 public class Language : ObjectG 44 { 45 /** the main Gtk struct */ 46 protected GtkSourceLanguage* gtkSourceLanguage; 47 48 /** Get the main Gtk struct */ 49 public GtkSourceLanguage* getLanguageStruct(bool transferOwnership = false) 50 { 51 if (transferOwnership) 52 ownedRef = false; 53 return gtkSourceLanguage; 54 } 55 56 /** the main Gtk struct as a void* */ 57 protected override void* getStruct() 58 { 59 return cast(void*)gtkSourceLanguage; 60 } 61 62 /** 63 * Sets our main struct and passes it to the parent class. 64 */ 65 public this (GtkSourceLanguage* gtkSourceLanguage, bool ownedRef = false) 66 { 67 this.gtkSourceLanguage = gtkSourceLanguage; 68 super(cast(GObject*)gtkSourceLanguage, ownedRef); 69 } 70 71 72 /** */ 73 public static GType getType() 74 { 75 return gtk_source_language_get_type(); 76 } 77 78 /** 79 * Returns the globs associated to this language. 80 * 81 * This is just an utility wrapper around [method@Language.get_metadata] to 82 * retrieve the "globs" metadata property and split it into an array. 83 * 84 * Returns: a newly-allocated %NULL terminated array containing the globs or %NULL 85 * if no globs are found. 86 * The returned array must be freed with g_strfreev(). 87 */ 88 public string[] getGlobs() 89 { 90 auto retStr = gtk_source_language_get_globs(gtkSourceLanguage); 91 92 scope(exit) Str.freeStringArray(retStr); 93 return Str.toStringArray(retStr); 94 } 95 96 /** 97 * Returns whether the language should be hidden from the user. 98 * 99 * Returns: %TRUE if the language should be hidden, %FALSE otherwise. 100 */ 101 public bool getHidden() 102 { 103 return gtk_source_language_get_hidden(gtkSourceLanguage) != 0; 104 } 105 106 /** 107 * Returns the ID of the language. 108 * 109 * The ID is not locale-dependent.The returned string is owned by @language 110 * and should not be freed or modified. 111 * 112 * Returns: the ID of @language. 113 */ 114 public string getId() 115 { 116 return Str.toString(gtk_source_language_get_id(gtkSourceLanguage)); 117 } 118 119 /** 120 * 121 * Params: 122 * name = metadata property name. 123 * Returns: value of property @name stored in 124 * the metadata of @language or %NULL if language does not contain the 125 * specified metadata property. 126 * The returned string is owned by @language and should not be freed 127 * or modified. 128 */ 129 public string getMetadata(string name) 130 { 131 return Str.toString(gtk_source_language_get_metadata(gtkSourceLanguage, Str.toStringz(name))); 132 } 133 134 /** 135 * Returns the mime types associated to this language. 136 * 137 * This is just an utility wrapper around [method@Language.get_metadata] to 138 * retrieve the "mimetypes" metadata property and split it into an 139 * array. 140 * 141 * Returns: a newly-allocated %NULL terminated array containing the mime types 142 * or %NULL if no mime types are found. 143 * The returned array must be freed with g_strfreev(). 144 */ 145 public string[] getMimeTypes() 146 { 147 auto retStr = gtk_source_language_get_mime_types(gtkSourceLanguage); 148 149 scope(exit) Str.freeStringArray(retStr); 150 return Str.toStringArray(retStr); 151 } 152 153 /** 154 * Returns the localized name of the language. 155 * 156 * The returned string is owned by @language and should not be freed 157 * or modified. 158 * 159 * Returns: the name of @language. 160 */ 161 public string getName() 162 { 163 return Str.toString(gtk_source_language_get_name(gtkSourceLanguage)); 164 } 165 166 /** 167 * Returns the localized section of the language. 168 * 169 * Each language belong to a section (ex. HTML belongs to the 170 * Markup section). 171 * The returned string is owned by @language and should not be freed 172 * or modified. 173 * 174 * Returns: the section of @language. 175 */ 176 public string getSection() 177 { 178 return Str.toString(gtk_source_language_get_section(gtkSourceLanguage)); 179 } 180 181 /** 182 * Returns the ID of the style to use if the specified @style_id 183 * is not present in the current style scheme. 184 * 185 * Params: 186 * styleId = a style ID. 187 * 188 * Returns: the ID of the style to use if the 189 * specified @style_id is not present in the current style scheme or %NULL 190 * if the style has no fallback defined. 191 * The returned string is owned by the @language and must not be modified. 192 */ 193 public string getStyleFallback(string styleId) 194 { 195 return Str.toString(gtk_source_language_get_style_fallback(gtkSourceLanguage, Str.toStringz(styleId))); 196 } 197 198 /** 199 * Returns the ids of the styles defined by this @language. 200 * 201 * Returns: a newly-allocated %NULL terminated array containing ids of the 202 * styles defined by this @language or %NULL if no style is defined. 203 * The returned array must be freed with g_strfreev(). 204 */ 205 public string[] getStyleIds() 206 { 207 auto retStr = gtk_source_language_get_style_ids(gtkSourceLanguage); 208 209 scope(exit) Str.freeStringArray(retStr); 210 return Str.toStringArray(retStr); 211 } 212 213 /** 214 * Returns the name of the style with ID @style_id defined by this @language. 215 * 216 * Params: 217 * styleId = a style ID. 218 * 219 * Returns: the name of the style with ID @style_id 220 * defined by this @language or %NULL if the style has no name or there is no 221 * style with ID @style_id defined by this @language. 222 * The returned string is owned by the @language and must not be modified. 223 */ 224 public string getStyleName(string styleId) 225 { 226 return Str.toString(gtk_source_language_get_style_name(gtkSourceLanguage, Str.toStringz(styleId))); 227 } 228 }